[Principles] Concrete Type or Interface for method return type?

Posted by SDReyes on Stack Overflow See other posts from Stack Overflow or by SDReyes
Published on 2010-04-21T00:02:32Z Indexed on 2010/04/21 0:13 UTC
Read the original article Hit count: 655

In general terms, whats the better election for a method's return type: a concrete type or an interface?

In most cases, I tend to use concrete types as the return type for methods. because I believe that an concrete type is more flexible for further use and exposes more functionality.

The dark side of this: Coupling. The angelic one: A concrete type contains per-se the interface you would going to return initially, and extra functionality.

What's your thumb's rule?

Is there any programming principle for this?


BONUS: This is an example of what I mean http://stackoverflow.com/questions/491375/readonlycollection-or-ienumerable-for-exposing-member-collections

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about design-principles